<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    /* 
      思路：https://leetcode-cn.com/problems/longest-increasing-subsequence/solution/fu-he-ren-lei-si-wei-de-dp-by-w1gapzyyt7/
    */
    let nums = [10,9,2,5,3,7,101,18];

    function lengthOfLIS(nums) {
      let n = nums.length;
      if (!n) return 0;

      let dp = new Array(n).fill(1);
      for (let i = 1; i < n; i++) 
        for (let j = 0; j < i; j++) 
          if (nums[i] > nums[j])
            dp[i] = Math.max(dp[i], dp[j] + 1);

      return Math.max(...dp);
    }
    console.log(lengthOfLIS(nums));
  </script>
</body>
</html>